package com.example.educational.aop;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect //定义切面
@Component
public class ReadPeoPleAop {

    //定义切入点
    @Pointcut("execution(* com.example.educational.service.ReadPeopleService .*(..))")
    public void pointCut() {
    }

    // 异常通知
    @AfterThrowing(value = "pointCut()", throwing = "ex")
    public void afterThrowingMethod(JoinPoint joinPoint, Throwable ex) {
        throw new RuntimeException("数据库服务异常，请管理员检查及时！！！");
    }

}
